package edu.mobbuzz.page.authorization;

import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Font;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.TextField;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;

public class Login {
    
    private Form loginForm;
    private Container buttonPanel;
    private Container loginPanel;
    
    private Label titleLbl;
    
    private Label usernameLbl;
    private Label passwordLbl;
    private TextField usernameTxt;
    private TextField passwordTxt;
    
    private Button loginBtn;
    private Command offlineCmd;
    private Command exitCmd;
    
    public Login(){
        loginForm = new Form();
        loginPanel = new Container();
        
        titleLbl = new Label();
        usernameLbl = new Label();
        passwordLbl = new Label();
        
        usernameTxt = new TextField();
        passwordTxt = new TextField();
        
        loginBtn = new Button();
        offlineCmd = new Command("Go Offline");
        exitCmd = new Command("Exit");
        
        buttonPanel = new Container(new com.sun.lwuit.layouts.FlowLayout(Component.LEFT));
    }
    
    public Form getLoginPage(){
        System.gc(); 
        titleLbl.setText("MoBBuZz Account");
        titleLbl.getStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM));
        usernameLbl.getStyle().setMargin(2, 10, 5, 2);  
        usernameLbl.setText("Username");
        usernameLbl.getStyle().setMargin(2, 2, 5, 2);
        usernameLbl.getStyle().setBgTransparency(0);
        usernameTxt.getStyle().setMargin(2, 2, 5, 10);
        
        passwordLbl.setText("Password");
        passwordLbl.getStyle().setMargin(2, 2, 5, 2);
        passwordLbl.getStyle().setBgTransparency(0);
        passwordTxt.getStyle().setMargin(2, 2, 5, 10);
        
        loginBtn.setText("Login");
        loginBtn.getStyle().setPadding(5, 5, 7, 7);
        
        buttonPanel.addComponent(loginBtn);
        buttonPanel.getStyle().setMargin(2, 2, 2, 2);
        
        loginPanel.setLayout(new BoxLayout(BoxLayout.Y_AXIS));      
        //loginPanel.getStyle().setBgImage(Theme.getBackground());      
        
        loginPanel.addComponent(titleLbl);
        loginPanel.addComponent(usernameLbl);
        loginPanel.addComponent(usernameTxt);
        loginPanel.addComponent(passwordLbl);
        loginPanel.addComponent(passwordTxt);
        loginPanel.addComponent(buttonPanel);
        
        loginForm.setLayout(new BorderLayout());
        loginForm.addComponent(BorderLayout.CENTER, loginPanel);   
        loginForm.addCommand(exitCmd);
        loginForm.addCommand(offlineCmd);
        loginForm.setBackCommand(exitCmd);       
        
        return loginForm;
        
        
    }

   
}
